package com.ideaaedi.commonds.lock;

import lombok.Getter;

import java.util.concurrent.TimeUnit;

/**
 * 获取 lock失败
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2100.9.8
 */
@Getter
public class NotAcquiredLockException extends RuntimeException {
    
    /**
     * 锁 key
     */
    private final String lockKey;
    
    /**
     * 等待获取锁的最大时长
     */
    private final long waitTime;
    
    /**
     * waitTime的时间单位
     */
    private final TimeUnit timeUnit;
    
    public NotAcquiredLockException(String lockKey, long waitTime, TimeUnit timeUnit) {
        super(String.format("lockKey=%s, waitTime=%d, timeUnit=%s", lockKey, waitTime, timeUnit));
        this.lockKey = lockKey;
        this.waitTime = waitTime;
        this.timeUnit = timeUnit;
    }
}
